package com.system.controller;

import com.common.annotation.MyLog;
import com.common.res.DataResult;
import com.system.service.ServerService;
import com.system.vo.response.Server;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/api")
@Api(tags = "服务器信息")
public class ServerController {

    @Autowired
    private ServerService serverService;

    @GetMapping("/tomcat")
    @ApiOperation("获取tomcat信息")
    @MyLog(title = "服务器信息",action = "获取tomcat信息")
    public DataResult<List<Server>> getTomcat(HttpServletRequest request){
        DataResult result = DataResult.success();
        result.setData(this.serverService.getServer("tomcat"));
        return result;
    }

    @GetMapping("/jvm")
    @ApiOperation("jvm")
    @MyLog(title = "服务器信息",action = "获取jvm信息")
    public DataResult<List<Server>> getJvm(){
        DataResult result = DataResult.success();
        result.setData(this.serverService.getServer("jvm"));
        return result;
    }
}
